//引入一级路由
import Home from "../views/home";
import Search from "../views/search";
import Login from "../views/login";
import Register from "../views/register";
import Detail from "../views/detail";
import AddCartSuccess from "../views/addCartSuccess";
import ShopCart from "../views/shopCart";
import Trade from '@/views/trade'; 
import Pay from '@/views/Pay';

export default [
  {
    path: "/home", //路径名字都是小写的
    component: Home,
    meta: { isShow: true },
  },
  {
    path: "/search/:keyword?",
    component: Search,
    meta: { isShow: true },
    //命名路由
    name: "search",
    //配置项:props可以给路由组件传递props
    //三种写法
    //第一种写法:布尔值写法
    // props: true,//可以params参数当中props传递给路由组件
    //第二种写法:对象写法 ---静态写法
    // props:{a:1,b:2,c:'豪哥'},//相当于给路由组件search传递三个props a b c
    //第三种写法:函数写法
    //即为当前路由
    // props: route=>({ a: 1, b: 2, c: '豪哥',path:route.path,meta:route.meta})
    //箭头函数返回结果对象:对象的属性当中props传递给search[props]
  },
  {
    path: "/login",
    component: Login,
    meta: { isShow: false },
  },
  {
    path: "/register",
    component: Register,
    meta: { isShow: false },
  },
  {
    //重定向
    path: "/",
    //redirect这个单词本身即为重定向
    redirect: "/home",
  },
  {
    path: "/detail/:skuId",
    component: Detail,
    meta: {
      isShow: true,
    },
  },
  {
    // 加入购物车成功页面,params携带商品数量
    path: "/addcartsuccess/:skuNum",
    name: "addcartsuccess",
    component: AddCartSuccess,
    meta: {
      isShow: true,
    },
  },
  {
    path: "/shopcart",
    component: ShopCart,
    meta: {
      isShow: true,
    },
  },
  {
    path:'/trade',
    component:Trade,
    meta:{
      isShow:true
    }
  },
  {
     path:'/pay',
     compoment:Pay,
     meta: {
      isShow: true
     }
  }
];
